feat: distinct latest resource collector#3130
feat: distinct latest resource collector#3130csviri wants to merge 7 commits intooperator-framework:nextfrom
Conversation
...-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtils.java
Outdated
Show resolved
Hide resolved
...-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtils.java
Outdated
Show resolved
Hide resolved
...mework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtilsTest.java
Outdated
Show resolved
Hide resolved
...mework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtilsTest.java
Outdated
Show resolved
Hide resolved
03cbf4c to
d7e21c5
Compare
| * @param <T> the type of HasMetadata objects | ||
| * @return a collector that produces a List of deduplicated Kubernetes objects | ||
| */ | ||
| public static <T extends HasMetadata> Collector<T, ?, List<T>> latestDistinctList() { |
There was a problem hiding this comment.
I don't get why this method or the set variant are needed or even useful. The semantic should be a Set since instances should be unique, no?
There was a problem hiding this comment.
The Set variant is needed since we are covering the use case whern there are multiple event sources for same type without distinct set of resource watched, so we returning the latest of those.
I added List just for convinience. If somebody would prefer working above Lists, that is quite common I beleive, but you are right that the semantically Set is the correct one.
There was a problem hiding this comment.
Ahh additional issue with adding it as default, is that this applies only for kubernetes resources, while in getSecondaryResources handles also external resources.
| new ResourceID(resource.getMetadata().getName(), resource.getMetadata().getNamespace()), | ||
| resource -> resource, | ||
| (existing, replacement) -> | ||
| compareResourceVersions(existing, replacement) >= 0 ? existing : replacement); |
There was a problem hiding this comment.
cc @metacosm this is the point to keep of this PR, just to keep the latest
There was a problem hiding this comment.
Wouldn't it be better if that was done transparently by the SDK? Also, wouldn't it be better to provide a filtered stream on Context rather than a Collector implementation?
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
…tor/api/reconciler/ReconcileUtils.java Co-authored-by: Martin Stefanko <xstefank122@gmail.com>
33e3d07 to
5a5027a
Compare
...-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtils.java
Show resolved
Hide resolved
...mework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/ReconcileUtilsTest.java
Outdated
Show resolved
Hide resolved
| new ResourceID(resource.getMetadata().getName(), resource.getMetadata().getNamespace()), | ||
| resource -> resource, | ||
| (existing, replacement) -> | ||
| compareResourceVersions(existing, replacement) >= 0 ? existing : replacement); |
There was a problem hiding this comment.
Wouldn't it be better if that was done transparently by the SDK? Also, wouldn't it be better to provide a filtered stream on Context rather than a Collector implementation?
|
replacced by: #3141 |
No description provided.